<?php
namespace Ad\Controller;

use Common\Controller\ApiController;

class AdController extends ApiController
{
    public function getBoardAds()
    {
        $input = $this->request();
        $where['site_id'] = $input['id']?$input['id']:1;
        if(!empty($input['sex'])){
            $where['sex'] = $input['sex'];
        }
        $ads = D('Ad')->scope('valid')
            ->where($where)
//            ->cache(7*24*60*60)    
            ->order('orderby asc')
            ->select();
        $ads = transform('Ad', 'pub', $ads);
        
        $this->response($ads);
    }
}
